import React from 'react'
import {Link} from 'react-router-dom'
import "./index.less"

function LinkTest({ color }) { 
    console.log("color: ", color);
    return <div>
        <h1 className={`color_change ${ color }`}>变色文字</h1>
        <div className="center">
            Link组件：&nbsp;&nbsp;&nbsp;&nbsp;
            <Link to="/linktest/red">变红色</Link>
            <Link to="/linktest/blue">变蓝色</Link>
        </div>
        <div className="center">
            a标签：&nbsp;&nbsp;&nbsp;&nbsp;
            <a href="/linktest/red">变红色</a>
            <a href="/linktest/blue">变蓝色</a>
        </div>
    </div>
}


LinkTest.getInitialProps = (ctx) => {
    const color = __isBrowser__ ? ctx.match.params.color : ctx.params.color;
    return {
        color
    }
}
  
export default LinkTest
  